package com.shrcl.engineerprocess.domain.proxy;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.shrcl.engineerprocess.domain.proxy.EngineerWorkOrderAction;

public class EngineerWorkOrderManager implements IsSerializable {
  public static Boolean isActionValid(final EngineerWorkOrderAction action, final String state) {
    if(action==null||state==null) return false;
    switch(action){
    	case $startexecute:{
    		return "created".equals(state);
    	}
    	case $taskFinish:{
    		return "executing".equals(state);
    	}
    	case $taskCancel:{
    		return "executing".equals(state);
    	}
    	case pendingApply:{
    		return "executing".equals(state);
    	}
    	case addAssignment:{
    		return "executing".equals(state);
    	}
    	case delAssignment:{
    		return "executing".equals(state);
    	}
    	case commitFinish:{
    		return "executing".equals(state);
    	}
    	case finish:{
    		return "committed".equals(state);
    	}
    	case pendingApprove:{
    		return "pendingApply".equals(state);
    	}
    	case pendingReject:{
    		return "pendingApply".equals(state);
    	}
    	default:
    		return false;
    }
    
  }
  
  public static Boolean isActionValid(final EngineerWorkOrderAction action, final Enum<?> state) {
    return isActionValid(action,state.name());
    
  }
}
